/**
 * 选择单个文章类别
 */
var zTree1 = null;
$(document).ready(function(){
	$("#articleCategoryTreeFrame").height($(window).height());
	zTree1 = $.fn.zTree.init($("#treeDemo"), setting);
});
var setting = {
	async: {
		enable: true,
		url: base + "/admin/system/articleCategory/treeData/2.jhtml",
		autoParam: ["id=parentId"],
		dataFilter: ajaxDataFilter
	},
	data: {
		simpleData: {
			enable: true
		}
	},
	callback: {
		onClick: clickNode
	}
};

/**
 * 返回json数据中有url且不为空,则点击会默认跳转到url属性链接，
 * 此函数用于过滤url不为空，则置空
 */
function ajaxDataFilter(treeId, parentNode, responseData) {
    if (responseData) {
      for(var i =0; i < responseData.length; i++) {
        if(responseData[i].url){
        	responseData[i].url = null;
        }
      }
    }
    return responseData;
};

//选中事件处理
function clickNode(event, treeId, treeNode, clickFlag){
	var url;
	if(treeNode.id){
		url = base + "/admin/system/article/list.jhtml?id=" + treeNode.id;
	}else{
		url = base + "/admin/system/article/list.jhtml";
	}
	parent.rightFrame.location = url;
}